<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>ARC Built-in Functions (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="ARC Built-in Functions (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="ARC Built-in Functions (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Target-Builtins.html" rel="up" title="Target Builtins">
<link href="ARC-SIMD-Built_002din-Functions.html" rel="next" title="ARC SIMD Built-in Functions">
<link href="Altera-Nios-II-Built_002din-Functions.html" rel="prev" title="Altera Nios II Built-in Functions">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en_US">
<div class="subsection-level-extent" id="ARC-Built_002din-Functions">
<div class="nav-panel">
<p>
Next: <a href="ARC-SIMD-Built_002din-Functions.html" accesskey="n" rel="next">ARC SIMD Built-in Functions</a>, Previous: <a href="Altera-Nios-II-Built_002din-Functions.html" accesskey="p" rel="prev">Altera Nios II Built-in Functions</a>, Up: <a href="Target-Builtins.html" accesskey="u" rel="up">Built-in Functions Specific to Particular Target Machines</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="ARC-Built_002din-Functions-1"><span>6.60.4 ARC Built-in Functions<a class="copiable-link" href="#ARC-Built_002din-Functions-1"> &para;</a></span></h4>

<p>The following built-in functions are provided for ARC targets.  The
built-ins generate the corresponding assembly instructions.  In the
examples given below, the generated code often requires an operand or
result to be in a register.  Where necessary further code will be
generated to ensure this is true, but for brevity this is not
described in each case.
</p>
<p><em class="emph">Note:</em> Using a built-in to generate an instruction not supported
by a target may cause problems. At present the compiler is not
guaranteed to detect such misuse, and as a result an internal compiler
error may be generated.
</p>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005faligned"><span class="category-def">Built-in Function: </span><span><code class="def-type">int</code> <strong class="def-name">__builtin_arc_aligned</strong> <code class="def-code-arguments">(void *<var class="var">val</var>, int <var class="var">alignval</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005faligned"> &para;</a></span></dt>
<dd><p>Return 1 if <var class="var">val</var> is known to have the byte alignment given
by <var class="var">alignval</var>, otherwise return 0.
Note that this is different from
</p><div class="example smallexample">
<pre class="example-preformatted">__alignof__(*(char *)<var class="var">val</var>) &gt;= alignval
</pre></div>
<p>because __alignof__ sees only the type of the dereference, whereas
__builtin_arc_align uses alignment information from the pointer
as well as from the pointed-to type.
The information available will depend on optimization level.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fbrk"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_brk</strong> <code class="def-code-arguments">(void)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fbrk"> &para;</a></span></dt>
<dd><p>Generates
</p><div class="example">
<pre class="example-preformatted">brk
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fcore_005fread"><span class="category-def">Built-in Function: </span><span><code class="def-type">unsigned int</code> <strong class="def-name">__builtin_arc_core_read</strong> <code class="def-code-arguments">(unsigned int <var class="var">regno</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fcore_005fread"> &para;</a></span></dt>
<dd><p>The operand is the number of a register to be read.  Generates:
</p><div class="example">
<pre class="example-preformatted">mov  <var class="var">dest</var>, r<var class="var">regno</var>
</pre></div>
<p>where the value in <var class="var">dest</var> will be the result returned from the
built-in.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fcore_005fwrite"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_core_write</strong> <code class="def-code-arguments">(unsigned int <var class="var">regno</var>, unsigned int <var class="var">val</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fcore_005fwrite"> &para;</a></span></dt>
<dd><p>The first operand is the number of a register to be written, the
second operand is a compile time constant to write into that
register.  Generates:
</p><div class="example">
<pre class="example-preformatted">mov  r<var class="var">regno</var>, <var class="var">val</var>
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fdivaw"><span class="category-def">Built-in Function: </span><span><code class="def-type">int</code> <strong class="def-name">__builtin_arc_divaw</strong> <code class="def-code-arguments">(int <var class="var">a</var>, int <var class="var">b</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fdivaw"> &para;</a></span></dt>
<dd><p>Only available if either <samp class="option">-mcpu=ARC700</samp> or <samp class="option">-meA</samp> is set.
Generates:
</p><div class="example">
<pre class="example-preformatted">divaw  <var class="var">dest</var>, <var class="var">a</var>, <var class="var">b</var>
</pre></div>
<p>where the value in <var class="var">dest</var> will be the result returned from the
built-in.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fflag"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_flag</strong> <code class="def-code-arguments">(unsigned int <var class="var">a</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fflag"> &para;</a></span></dt>
<dd><p>Generates
</p><div class="example">
<pre class="example-preformatted">flag  <var class="var">a</var>
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005flr"><span class="category-def">Built-in Function: </span><span><code class="def-type">unsigned int</code> <strong class="def-name">__builtin_arc_lr</strong> <code class="def-code-arguments">(unsigned int <var class="var">auxr</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005flr"> &para;</a></span></dt>
<dd><p>The operand, <var class="var">auxv</var>, is the address of an auxiliary register and
must be a compile time constant.  Generates:
</p><div class="example">
<pre class="example-preformatted">lr  <var class="var">dest</var>, [<var class="var">auxr</var>]
</pre></div>
<p>Where the value in <var class="var">dest</var> will be the result returned from the
built-in.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fmul64"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_mul64</strong> <code class="def-code-arguments">(int <var class="var">a</var>, int <var class="var">b</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fmul64"> &para;</a></span></dt>
<dd><p>Only available with <samp class="option">-mmul64</samp>.  Generates:
</p><div class="example">
<pre class="example-preformatted">mul64  <var class="var">a</var>, <var class="var">b</var>
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fmulu64"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_mulu64</strong> <code class="def-code-arguments">(unsigned int <var class="var">a</var>, unsigned int <var class="var">b</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fmulu64"> &para;</a></span></dt>
<dd><p>Only available with <samp class="option">-mmul64</samp>.  Generates:
</p><div class="example">
<pre class="example-preformatted">mulu64  <var class="var">a</var>, <var class="var">b</var>
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fnop"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_nop</strong> <code class="def-code-arguments">(void)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fnop"> &para;</a></span></dt>
<dd><p>Generates:
</p><div class="example">
<pre class="example-preformatted">nop
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fnorm"><span class="category-def">Built-in Function: </span><span><code class="def-type">int</code> <strong class="def-name">__builtin_arc_norm</strong> <code class="def-code-arguments">(int <var class="var">src</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fnorm"> &para;</a></span></dt>
<dd><p>Only valid if the &lsquo;<samp class="samp">norm</samp>&rsquo; instruction is available through the
<samp class="option">-mnorm</samp> option or by default with <samp class="option">-mcpu=ARC700</samp>.
Generates:
</p><div class="example">
<pre class="example-preformatted">norm  <var class="var">dest</var>, <var class="var">src</var>
</pre></div>
<p>Where the value in <var class="var">dest</var> will be the result returned from the
built-in.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fnormw"><span class="category-def">Built-in Function: </span><span><code class="def-type">short int</code> <strong class="def-name">__builtin_arc_normw</strong> <code class="def-code-arguments">(short int <var class="var">src</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fnormw"> &para;</a></span></dt>
<dd><p>Only valid if the &lsquo;<samp class="samp">normw</samp>&rsquo; instruction is available through the
<samp class="option">-mnorm</samp> option or by default with <samp class="option">-mcpu=ARC700</samp>.
Generates:
</p><div class="example">
<pre class="example-preformatted">normw  <var class="var">dest</var>, <var class="var">src</var>
</pre></div>
<p>Where the value in <var class="var">dest</var> will be the result returned from the
built-in.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005frtie"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_rtie</strong> <code class="def-code-arguments">(void)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005frtie"> &para;</a></span></dt>
<dd><p>Generates:
</p><div class="example">
<pre class="example-preformatted">rtie
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fsleep"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_sleep</strong> <code class="def-code-arguments">(int <var class="var">a</var></code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fsleep"> &para;</a></span></dt>
<dd><p>Generates:
</p><div class="example">
<pre class="example-preformatted">sleep  <var class="var">a</var>
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fsr"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_sr</strong> <code class="def-code-arguments">(unsigned int <var class="var">val</var>, unsigned int <var class="var">auxr</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fsr"> &para;</a></span></dt>
<dd><p>The first argument, <var class="var">val</var>, is a compile time constant to be
written to the register, the second argument, <var class="var">auxr</var>, is the
address of an auxiliary register.  Generates:
</p><div class="example">
<pre class="example-preformatted">sr  <var class="var">val</var>, [<var class="var">auxr</var>]
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fswap"><span class="category-def">Built-in Function: </span><span><code class="def-type">int</code> <strong class="def-name">__builtin_arc_swap</strong> <code class="def-code-arguments">(int <var class="var">src</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fswap"> &para;</a></span></dt>
<dd><p>Only valid with <samp class="option">-mswap</samp>.  Generates:
</p><div class="example">
<pre class="example-preformatted">swap  <var class="var">dest</var>, <var class="var">src</var>
</pre></div>
<p>Where the value in <var class="var">dest</var> will be the result returned from the
built-in.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fswi"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_swi</strong> <code class="def-code-arguments">(void)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fswi"> &para;</a></span></dt>
<dd><p>Generates:
</p><div class="example">
<pre class="example-preformatted">swi
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005fsync"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_sync</strong> <code class="def-code-arguments">(void)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005fsync"> &para;</a></span></dt>
<dd><p>Only available with <samp class="option">-mcpu=ARC700</samp>.  Generates:
</p><div class="example">
<pre class="example-preformatted">sync
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005ftrap_005fs"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_trap_s</strong> <code class="def-code-arguments">(unsigned int <var class="var">c</var>)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005ftrap_005fs"> &para;</a></span></dt>
<dd><p>Only available with <samp class="option">-mcpu=ARC700</samp>.  Generates:
</p><div class="example">
<pre class="example-preformatted">trap_s  <var class="var">c</var>
</pre></div>
</dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-_005f_005fbuiltin_005farc_005funimp_005fs"><span class="category-def">Built-in Function: </span><span><code class="def-type">void</code> <strong class="def-name">__builtin_arc_unimp_s</strong> <code class="def-code-arguments">(void)</code><a class="copiable-link" href="#index-_005f_005fbuiltin_005farc_005funimp_005fs"> &para;</a></span></dt>
<dd><p>Only available with <samp class="option">-mcpu=ARC700</samp>.  Generates:
</p><div class="example">
<pre class="example-preformatted">unimp_s
</pre></div>
</dd></dl>

<p>The instructions generated by the following builtins are not
considered as candidates for scheduling.  They are not moved around by
the compiler during scheduling, and thus can be expected to appear
where they are put in the C code:
</p><div class="example">
<pre class="example-preformatted">__builtin_arc_brk()
__builtin_arc_core_read()
__builtin_arc_core_write()
__builtin_arc_flag()
__builtin_arc_lr()
__builtin_arc_sleep()
__builtin_arc_sr()
__builtin_arc_swi()
</pre></div>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="ARC-SIMD-Built_002din-Functions.html">ARC SIMD Built-in Functions</a>, Previous: <a href="Altera-Nios-II-Built_002din-Functions.html">Altera Nios II Built-in Functions</a>, Up: <a href="Target-Builtins.html">Built-in Functions Specific to Particular Target Machines</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
